<?php

require_once dirname(__FILE__) . '/../lib/descuentosGeneratorConfiguration.class.php';
require_once dirname(__FILE__) . '/../lib/descuentosGeneratorHelper.class.php';

/**
 * descuentos actions.
 *
 * @package    tercermilenio
 * @subpackage descuentos
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 12474 2008-10-31 10:41:27Z fabien $
 */
class descuentosActions extends autoDescuentosActions {

    public function executeIndex(sfWebRequest $request) {

        $existe = DescuentosPeer::existe();

        if (!$existe) {
            $this->redirect('@descuentos_new');
        } else {
            $descuentos = DescuentosPeer::doSelectOne(new Criteria());


            $this->redirect(array('sf_route' => 'descuentos_edit', 'sf_subject' => $descuentos));
            //$this->redirect('comercios/edit?' . $comId);
        }
    }

    public function executeEdit(sfWebRequest $request) {
        $this->descuentos = $this->getRoute()->getObject();
        $this->form = $this->configuration->getForm($this->descuentos);
    }

    public function executeBackToMenu(){
        $this->redirect('@homepage');
    }

}
